home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / KOOB / creator / editor / AIEButtonBarDlg.gui next >
Text File  |  2005-11-23  |  14KB  |  518 lines

  1. //--- OBJECT WRITE BEGIN ---
  2. new GuiControl(AIEButtonBarDlg) {
  3.     profile = "GuiModelessDialogProfile";
  4.     horizSizing = "right";
  5.     vertSizing = "bottom";
  6.     position = "0 0";
  7.     extent = "640 480";
  8.     minExtent = "8 8";
  9.     visible = "1";
  10.     helpTag = "0";
  11.  
  12.     new GuiChunkedBitmapCtrl() {
  13.         profile = "GuiContentProfile";
  14.         horizSizing = "right";
  15.         vertSizing = "height";
  16.         position = "0 30";
  17.         extent = "120 420";
  18.         minExtent = "8 8";
  19.         visible = "1";
  20.         helpTag = "0";
  21.  
  22.         new GuiCheckBoxCtrl(ExteriorCheckBox) {
  23.             profile = "GuiButtonProfile";
  24.             horizSizing = "right";
  25.             vertSizing = "bottom";
  26.             position = "11 23";
  27.             extent = "100 22";
  28.             minExtent = "8 8";
  29.             visible = "1";
  30.             command = "ExteriorCheckBox.updateCheckBox();";
  31.             helpTag = "0";
  32.             text = "Draw Ext";
  33.         };
  34.         new GuiCheckBoxCtrl(InteriorCheckBox) {
  35.             profile = "GuiButtonProfile";
  36.             horizSizing = "right";
  37.             vertSizing = "bottom";
  38.             position = "11 47";
  39.             extent = "100 22";
  40.             minExtent = "8 8";
  41.             visible = "1";
  42.             command = "InteriorCheckBox.updateCheckBox();";
  43.             helpTag = "0";
  44.             text = "Draw Int";
  45.         };
  46.         new GuiTextCtrl() {
  47.             profile = "GuiTextProfile";
  48.             horizSizing = "right";
  49.             vertSizing = "bottom";
  50.             position = "11 6";
  51.             extent = "73 18";
  52.             minExtent = "8 8";
  53.             visible = "1";
  54.             helpTag = "0";
  55.             text = "Visual Options:";
  56.         };
  57.         new GuiCheckBoxCtrl(JetConnectionsCheckBox) {
  58.             profile = "GuiButtonProfile";
  59.             horizSizing = "right";
  60.             vertSizing = "bottom";
  61.             position = "11 73";
  62.             extent = "100 22";
  63.             minExtent = "8 8";
  64.             visible = "1";
  65.             command = "JetConnectionsCheckBox.updateCheckBox();";
  66.             helpTag = "0";
  67.             text = "Draw Jet";
  68.         };
  69.         new GuiButtonCtrl() {
  70.             profile = "GuiButtonProfile";
  71.             horizSizing = "right";
  72.             vertSizing = "bottom";
  73.             position = "10 201";
  74.             extent = "100 29";
  75.             minExtent = "8 8";
  76.             visible = "1";
  77.             command = "makeJettableGraph(Nav);";
  78.             helpTag = "0";
  79.             text = "Bot Graph";
  80.         };
  81.         new GuiButtonCtrl() {
  82.             profile = "GuiButtonProfile";
  83.             horizSizing = "right";
  84.             vertSizing = "bottom";
  85.             position = "10 169";
  86.             extent = "100 29";
  87.             minExtent = "8 8";
  88.             visible = "1";
  89.             command = "makeJettableGraph(Spawn);";
  90.             helpTag = "0";
  91.             text = "Spawn Graph";
  92.         };
  93.         new GuiButtonCtrl() {
  94.             profile = "GuiButtonProfile";
  95.             horizSizing = "right";
  96.             vertSizing = "bottom";
  97.             position = "10 233";
  98.             extent = "100 29";
  99.             minExtent = "8 8";
  100.             visible = "1";
  101.             command = "AIEButtonBarDlg.createLOSXref();";
  102.             helpTag = "0";
  103.             text = "Build LOS";
  104.         };
  105.         new GuiButtonCtrl() {
  106.             profile = "GuiButtonProfile";
  107.             horizSizing = "right";
  108.             vertSizing = "bottom";
  109.             position = "10 265";
  110.             extent = "100 29";
  111.             minExtent = "8 8";
  112.             visible = "1";
  113.             command = "navGraph.saveGraph();";
  114.             helpTag = "0";
  115.             text = "Save";
  116.         };
  117.         new GuiTextCtrl() {
  118.             profile = "GuiTextProfile";
  119.             horizSizing = "right";
  120.             vertSizing = "bottom";
  121.             position = "11 151";
  122.             extent = "56 18";
  123.             minExtent = "8 8";
  124.             visible = "1";
  125.             helpTag = "0";
  126.             text = "Graph Build";
  127.         };
  128.         new GuiTextCtrl() {
  129.             profile = "GuiTextProfile";
  130.             horizSizing = "right";
  131.             vertSizing = "bottom";
  132.             position = "11 315";
  133.             extent = "64 18";
  134.             minExtent = "8 8";
  135.             visible = "1";
  136.             helpTag = "0";
  137.             text = "AI Objectives";
  138.         };
  139.         new GuiButtonCtrl() {
  140.             profile = "GuiButtonProfile";
  141.             horizSizing = "right";
  142.             vertSizing = "bottom";
  143.             position = "10 331";
  144.             extent = "100 29";
  145.             minExtent = "8 8";
  146.             visible = "1";
  147.             command = "AICreateObjectives();";
  148.             helpTag = "0";
  149.             text = "Build Objectives";
  150.         };
  151.         new GuiPopUpMenuCtrl(ObjectiveList) {
  152.             profile = "GuiPopUpProfile";
  153.             horizSizing = "right";
  154.             vertSizing = "bottom";
  155.             position = "10 368";
  156.             extent = "101 20";
  157.             minExtent = "8 8";
  158.             visible = "1";
  159.             helpTag = "0";
  160.             text = "New Objective";
  161.             maxPopupHeight = "200";
  162.         };
  163.         new GuiButtonCtrl() {
  164.             profile = "GuiButtonProfile";
  165.             horizSizing = "right";
  166.             vertSizing = "bottom";
  167.             position = "10 395";
  168.             extent = "100 29";
  169.             minExtent = "8 8";
  170.             visible = "1";
  171.             command = "AISaveMissionObjectives();";
  172.             helpTag = "0";
  173.             text = "Save";
  174.         };
  175.         new GuiTextCtrl() {
  176.             profile = "GuiTextProfile";
  177.             horizSizing = "right";
  178.             vertSizing = "bottom";
  179.             position = "10 102";
  180.             extent = "73 18";
  181.             minExtent = "8 8";
  182.             visible = "1";
  183.             helpTag = "0";
  184.             text = "Camera speed:";
  185.         };
  186.         new GuiSliderCtrl() {
  187.             profile = "GuiDefaultProfile";
  188.             horizSizing = "right";
  189.             vertSizing = "bottom";
  190.             position = "6 121";
  191.             extent = "80 20";
  192.             minExtent = "80 20";
  193.             visible = "1";
  194.             variable = "value";
  195.             command = "$Camera::movementSpeed = $ThisControl.getValue();";
  196.             helpTag = "0";
  197.             range = "0.000000 200.000000";
  198.             ticks = "10";
  199.             value = "20";
  200.         };
  201.     };
  202. };
  203. //--- OBJECT WRITE END ---
  204.  
  205. //------------------------------------------------------------------------------
  206. // Functions
  207. //------------------------------------------------------------------------------
  208.  
  209. function makeUnbridgedGraph()
  210. {
  211.    GraphCurrentOperation.setValue("Generating interior nodes...");
  212.    Canvas.repaint();   
  213.    navGraph::generateInterior();
  214.    dataProgress();
  215.    
  216.    GraphCurrentOperation.setValue("Remaking graph...");
  217.    Canvas.repaint();   
  218.    remakeTheGraph();
  219.    dataProgress();
  220. }
  221.  
  222. function makeJettableGraph(%NAVorSPAWN)
  223. {
  224.    AIworking(true);
  225.    
  226.       $NavGraph::operations = 7;
  227.       $NavGraph::operationsDone = 0;
  228.    
  229.       navGraph.setGenMode(%NAVorSPAWN);
  230.       navGraph::exteriorInspect();
  231.       dataProgress();
  232.       makeUnbridgedGraph();
  233.    
  234.       GraphCurrentOperation.setValue("Beginning slow bridge finding pass");
  235.       Canvas.repaint();
  236.       
  237.       navGraph.assemble();
  238.       
  239.       navGraph.cullIslands();
  240.       remakeTheGraph();
  241.       navGraph.pushBridges();
  242.       navGraph.makeTables();
  243.       dataProgress();
  244.       
  245.    AIworking(false);
  246. }
  247.  
  248. //------------------------------------------------------------------------------
  249.  
  250. function AIEButtonBarDlg::getPrefs(%this)
  251. {
  252. }
  253.  
  254. //------------------------------------------------------------------------------
  255.  
  256. function AIEbuttonBarDlg::setPrefs(%this)
  257. {
  258. }
  259.  
  260. //------------------------------------------------------------------------------
  261.  
  262. function AIEButtonBarDlg::init(%this)
  263. {
  264.    InteriorCheckBox.setValue($pref::NavGraph::drawIndoor);
  265.    ExteriorCheckBox.setValue($pref::NavGraph::drawOutdoor);
  266.    
  267.    if(!$pref::NavGraph::drawIndoor)
  268.       JetConnectionsCheckBox.visible = false;
  269.    
  270.    JetConnectionsCheckBox.setValue($pref::NavGraph::drawJetEdges);
  271.    
  272.    ObjectiveList.clear();
  273.    ObjectiveList.setText("New Objective");
  274.    ObjectiveList.add("Deploy Outdoor Turret", 1);
  275.    ObjectiveList.add("Deploy Indoor Turret", 2);
  276.    ObjectiveList.add("Deploy Inventory", 3);
  277.    ObjectiveList.add("Touch FlipFlop", 4);
  278.    ObjectiveList.add("Mortar Target", 5);
  279.    ObjectiveList.add("Repair Equipment", 6);
  280.    ObjectiveList.add("Attack Target", 7);
  281.    ObjectiveList.add("Defend Location", 8);
  282.    objectiveList.add("New Group", 9);
  283.    
  284.    //ObjectivesList.sort();
  285. }
  286.  
  287. //------------------------------------------------------------------------------
  288.  
  289. function AIEButtonBarDlg::onSleep(%this)
  290. {
  291. }
  292.  
  293. //------------------------------------------------------------------------------
  294.  
  295. function AIEButtonBarDlg::onWake(%this)
  296. {
  297. }
  298.  
  299. //------------------------------------------------------------------------------
  300.  
  301. function dataProgress()
  302. {
  303.    $NavGraph::operationsDone++;
  304.    %percent = $NavGraph::operationsDone / $NavGraph::operations;
  305.    GraphBuildProgress.setValue(%percent);
  306.    Canvas.repaint();   
  307. }
  308.  
  309. //------------------------------------------------------------------------------
  310.  
  311. function remakeTheGraph()
  312. {
  313.    GraphCurrentOperation.setValue("making graph...");
  314.    Canvas.repaint();   
  315.    navGraph.makeGraph();
  316.    dataProgress();
  317. }
  318.  
  319. //------------------------------------------------------------------------------
  320.  
  321. function AIEButtonBarDlg::createLOSXref()
  322. {
  323.    AIworking(true);
  324.       GraphCurrentOperation.setValue("Making LOS CrossRef Table...");
  325.       GraphBuildProgress.setValue(0);
  326.    
  327.       if(2.player)
  328.          navGraph.prepLOS(2.player.getTransform());
  329.       else
  330.          navGraph.prepLOS("0 0 0");
  331.       
  332.       while(navGraph.makeLOS())
  333.       {
  334.          GraphBuildProgress.setValue($graphProcessPercent);
  335.          Canvas.repaint();   
  336.       }
  337.       GraphBuildProgress.setValue(100);
  338.       Canvas.repaint();   
  339.    AIworking(false);
  340. }
  341.  
  342. function ExteriorCheckBox::updateCheckBox()
  343. {
  344.    $pref::NavGraph::drawOutdoor = !$pref::NavGraph::drawOutdoor;
  345. }
  346.  
  347. function InteriorCheckBox::updateCheckBox()
  348. {
  349.    $pref::NavGraph::drawIndoor = !$pref::NavGraph::drawIndoor;
  350.    
  351.    if(!$pref::NavGraph::drawIndoor)
  352.       JetConnectionsCheckBox.visible = false;
  353.    else
  354.       jetConnectionsCheckBox.visible = true;
  355. }
  356.  
  357. function JetConnectionsCheckBox::updateCheckBox()
  358. {
  359.    $pref::NavGraph::drawJetEdges = !$pref::NavGraph::drawJetEdges;
  360. }
  361.  
  362. function AISaveMissionObjectives()
  363. {
  364.    // once we have created all objecitves, save out the mis file
  365.    if(!isObject(MissionGroup))
  366.    {
  367.       error("No mission exists!");
  368.       return;
  369.    }
  370.    
  371.    // check for read-only
  372.    %file = "FixMe/missions/" @ $Client::MissionFile;
  373.    if(!isWriteableFileName(%file))
  374.    {
  375.       error("Mission file '" @ %file @ "' is not writeable.");
  376.       return; 
  377.    }
  378.    
  379.    // ok, were good to save.
  380.    missionGroup.save("missions/" @ $Client::MissionFile);
  381. }
  382.  
  383. function AIObjectivesLock(%lock)
  384. {
  385.    %numTeams = nameToId("MissionGroup/Teams").getCount();
  386.  
  387.    for(%j = 0; %j < %numTeams; %j++)
  388.    {
  389.       %objGroup = nameToId("MissionGroup/Teams/team" @ %j @ "/AIObjectives");
  390.       if(%objGroup == -1)
  391.          continue;
  392.  
  393.       %objCount = %objGroup.getCount();
  394.    
  395.       for(%i = 0; %i < %objCount; %i++)
  396.       {
  397.          %obj = %objGroup.getObject(%i);
  398.          %obj.locked = %lock;
  399.       }
  400.    }   
  401.    
  402.    // save
  403.    AISaveMissionObjectives();
  404. }
  405.  
  406. function addNewObjective(%type)
  407. {
  408.    if($AIEditor::inspectTeam == 1)
  409.       %team = 1;
  410.    else if($AIEditor::inspectTeam == 2)
  411.       %team = 2;
  412.    else 
  413.       %team = 1;
  414.    
  415.    %tGroup = nameToId("MissionGroup/Teams/team" @ %team @ "/AIObjectives");
  416.    
  417.    if(%tGroup < 1)
  418.       return;
  419.       
  420.    if($InstantGroup $= "MissionGroup")
  421.       $InstantGroup = %tGroup;
  422.       
  423.    switch$(%type)
  424.    {
  425.       case "Defend Location":
  426.          %objective = new AIObjective(AIODefendLocation)
  427.          {
  428.               dataBlock = "AIObjectiveMarker";
  429.          };
  430.       case "Repair Equipment":
  431.          %objective = new AIObjective(AIORepairObject)
  432.          {
  433.               dataBlock = "AIObjectiveMarker";
  434.          };
  435.       case "Deploy Outdoor Turret":
  436.          %Objective = new AIObjective(AIODeployEquipment)
  437.           {
  438.               dataBlock = "AIObjectiveMarker";
  439.             weightLevel1 = 4100;
  440.               weightLevel2 = 0;
  441.               description = "Deploy outdoor Turret";
  442.               offense = false;
  443.               defense = true;
  444.             targetObjectId = -1;
  445.             targetObject = -1;
  446.             targetClientId = -1;
  447.             equipment = "TurretOutdoorDeployable";
  448.               buyEquipmentSet = "MediumOutdoorTurretSet";
  449.           };
  450.       case "Deploy Indoor Turret":
  451.          %Objective = new AIObjective(AIODeployEquipment)
  452.           {
  453.               dataBlock = "AIObjectiveMarker";
  454.             weightLevel1 = 4100;
  455.               weightLevel2 = 0;
  456.               description = "Deploy indoor Turret";
  457.               offense = false;
  458.               defense = true;
  459.             targetObjectId = -1;
  460.             targetObject = -1;
  461.             targetClientId = -1;
  462.             equipment = "TurretIndoorDeployable";
  463.               buyEquipmentSet = "MediumIndoorTurretSet";
  464.           };
  465.       case "Attack Target":
  466.          %objective = new AIObjective(AIOAttackObject)
  467.          {
  468.               dataBlock = "AIObjectiveMarker";
  469.          };
  470.       case "Touch FlipFlop":
  471.          %objective = new AIObjective(AIOTouchObject)
  472.          {
  473.               dataBlock = "AIObjectiveMarker";
  474.          };
  475.       case "Mortar Target":
  476.          %objective = new AIObjective(AIOMortarObject)
  477.          {
  478.               dataBlock = "AIObjectiveMarker";
  479.          };
  480.       case "Deploy Inventory":
  481.          %Objective = new AIObjective(AIODeployEquipment)
  482.           {
  483.               dataBlock = "AIObjectiveMarker";
  484.             weightLevel1 = 4100;
  485.               weightLevel2 = 0;
  486.               description = "Deploy Inventory Station";
  487.               offense = false;
  488.               defense = true;
  489.             targetObjectId = -1;
  490.             targetObject = -1;
  491.             targetClientId = -1;
  492.             equipment = "InventoryDeployable";
  493.               buyEquipmentSet = "MediumInventorySet";
  494.           };
  495.       case "New Group":
  496.          %set = new SimGroup("ObjectiveSet");
  497.          %tGroup.add(%set);
  498.          return;
  499.       default:
  500.          error("no defined type.");
  501.          return;      
  502.    }
  503.    
  504.    $InstantGroup.add(%objective);
  505.    aiEdit.clearSelection();
  506.    aiEdit.selectObject(%objective);
  507.    aiEdit.dropSelection();
  508.    %objective.location = %objective.getWorldBoxCenter();
  509.    Inspector.inspect(%objective);
  510.    InspectorNameEdit.setValue(%objective.getName());
  511. }
  512.  
  513. function ObjectiveList::onSelect(%this, %id, %text)
  514. {  
  515.    addNewObjective(%text);
  516.    ObjectiveList.setText("New Objective");
  517. }
  518.